/**
 * 
 * @author pijun
 *
 * basic gui for the calendar system.
 */
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;

public class Gui extends JFrame
{
	private static final int WIDTH = 800;
	private static final int HEIGHT = 600;
	
	private JLabel nameL, commentL, geoL, locationL, resourceL, DTstartL, DTendL, tzidL;
	private JTextField nameTF, commentTF, geoTF, locationTF, resourceTF, DTstartTF, DTendTF, tzidTF;
	private JButton  exitB, submit;
	public String[] textfield = new String[7];
	
	//Buttons:
	private ExitButtonHandler ebHandler;
	private SubmitButtonHandler SbHandler;
	
	
	public Gui()
	{
		//labels for each of the text fields
		nameL = new JLabel("Enter name of event:", SwingConstants.RIGHT);
		commentL = new JLabel("Enter comments:", SwingConstants.RIGHT);
		geoL = new JLabel("Enter the geo position:", SwingConstants.RIGHT);
		locationL = new JLabel("Enter the location:", SwingConstants.RIGHT);
		resourceL = new JLabel("Enter the resources:", SwingConstants.RIGHT);
		DTstartL = new JLabel("Enter the Start time: ", SwingConstants.RIGHT);						
		DTendL = new JLabel("Enter the end time:", SwingConstants.RIGHT);
		tzidL = new JLabel("Enter the timezone:", SwingConstants.RIGHT);
				
		//text fields
		nameTF = new JTextField(10);
		commentTF = new JTextField(10);
		geoTF = new JTextField(10);
		locationTF = new JTextField(10);
		resourceTF = new JTextField(10);
		DTstartTF = new JTextField(10);
		DTendTF = new JTextField(10);
		tzidTF = new JTextField(10);
		
		
		//SPecify handlers for each button and add (register) ActionListeners to each button.
		//exit button handler
		exitB = new JButton("Exit");
		ebHandler = new ExitButtonHandler();
		exitB.addActionListener(ebHandler);
		
		//submit button handler
		submit = new JButton("Submit");
		SbHandler = new SubmitButtonHandler();
		submit.addActionListener(SbHandler);
		
		
		setTitle("Event Creator");
		Container pane = getContentPane();
		pane.setLayout(new GridLayout(9, 2));
		
		//Add things to the pane in the order you want them to appear (left to right, top to bottom)
		pane.add(nameL);
		pane.add(nameTF);
		pane.add(commentL);
		pane.add(commentTF);
		pane.add(geoL);
		pane.add(geoTF);
		pane.add(locationL);
		pane.add(locationTF);
		pane.add(resourceL);
		pane.add(resourceTF);
		pane.add(DTstartL);
		pane.add(DTstartTF);
		pane.add(DTendL);
		pane.add(DTendTF);
		pane.add(tzidL);
		pane.add(tzidTF);
		pane.add(exitB);
		pane.add(submit);
		
		setSize(WIDTH, HEIGHT);
		setVisible(true);
		setDefaultCloseOperation(EXIT_ON_CLOSE);
	}
	
	public class ExitButtonHandler implements ActionListener
	{
		public void actionPerformed(ActionEvent e)
		{
			System.exit(0);
		}
	}
	
	public class SubmitButtonHandler implements ActionListener{
		public void actionPerformed(ActionEvent e){
			//puts all the users data into an array
			String[] array;
			array = new String[7];
			array[0] = nameTF.getText();
			array[1] = commentTF.getText();
			array[2] = geoTF.getText();
			array[3] = locationTF.getText();
			array[4] = resourceTF.getText();
			array[5] = DTstartTF.getText();
			array[6] = DTendTF.getText();
			array[7] = tzidTF.getText();
		}
	}
	
	public static void main(String[] args)
	{
		Gui rectObj = new Gui();
	}
	
}